package com.mall.search.server.controller;

import com.alibaba.fastjson.JSONArray;
import com.mall.common.core.domain.Result;
import com.mall.search.common.domain.SkuEsModel;
import com.mall.search.server.service.EsSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@RequestMapping("/es/save")
@RestController
public class EsSaveController {

    @Autowired
    private EsSaveService esSaveService;


    /**
     * 将上架的sku信息保存到es中
     * @param
     * @return
     */
    @PostMapping("/saveSkuByPublish")
    public Result saveSkuByPublish(@RequestBody String jsonString){

        boolean b = esSaveService.saveSkuByPublish(jsonString);
        if(b==true){
            return Result.error();
        }else {
            return Result.success();
        }
    }
}

